﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using OgilvyOne.UKNow.BLL;
using OgilvyOne.UKNow.Mobile.Model.Events;
using OgilvyOne.UKNow.Model;
using ECCIT.Extension.Weibo_v2.Common;
using OgilvyOne.UKNow.Mobile.Utilities;
using OgilvyOne.UKNow.Configuration;

namespace OgilvyOne.UKNow.Mobile.APIs.Events
{
    public class Show : IHttpHandler
    {
        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            try
            {
                int eid = Convert.ToInt32(context.Request.Params["eventid"].ToString());
                getDesc(eid, context);
            }
            catch (Exception)
            {
                context.Response.Write(ResultUtility.ReturnResultJson("-612", "", "获取活动详细信息失败"));
            }
        }

        private void getDesc(int eid, HttpContext htc)
        {
            EventsBLL ebll = new EventsBLL(2052);
            EventsModel em = ebll.selEvent(eid);
            EventInfo elac = ModelConvertUtility.ToEventInfo(em, true);

            // 获取相关活动
            IList<EventsModel> models = ebll.GetSeriesEvents(em.ID, false);
            elac.OtherCities = new List<string>();
            foreach (EventsModel model in models)
            {
                elac.OtherCities.Add(model.CityModel.Cnname);
            }
            string s = JsonSerializationHelper.ObjectToJson(elac);
            htc.Response.Write(ResultUtility.ReturnResultJson("0", s, "获取活动详细信息成功"));
        }
    }
}
